<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="userForm" enctype="multipart/form-data">
                <br/>
                <h3 class="title">Pesquisar Usuário</h3>

                <p:growl id="messages" showDetail="false" autoUpdate="true"  /> 

                <p:panel id="filtrosPanel" styleClass="clearfix container_24 withoutBorder">

                    <h4 class="title">Pesquisar</h4>
                    <p:outputLabel value="Nome" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuarioPesquisar.nome}" />

                    <p:outputLabel value="Profissão" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuarioPesquisar.profissao}" />

                </p:panel>

                <div class="buttonAction">
                    <p:commandButton  id="pesquisarCommandButton" value="Pesquisar" icon="ui-icon-search"
                                      update="@form, tableUser"
                                      actionListener="#{managerPesquisarUsuario.pesquisar()}"
                                      styleClass="ui-priority-primary" />
                    <p:commandButton value="Limpar" update="@form" icon="ui-icon-clean"
                                     actionListener="#{managerPesquisarUsuario.limpar()}" />
                </div>

                <p:blockUI id="BLOCK" block="resultPanel" trigger="pesquisarCommandButton, tableUser" > 
                    <p:graphicImage value="/media/images/ajax-loader.gif"/>
                </p:blockUI>

                <p:panel id="resultadosPanel" styleClass="clearfix container_24 withoutBorder">
                    <h4 class="title">Resultado</h4>
                    <p:panel id="resultPanel" styleClass="container_24 clearfix ">

                        <p:dataTable id="tableUser" var="u" value="#{managerPesquisarUsuario.dataModel}" 
                                     styleClass="grid_24" rowIndexVar="rowid"
                                     binding="#{managerPesquisarUsuario.searchResults}"
                                     rows="5" paginator="true" lazy="true"   
                                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                     currentPageReportTemplate="{currentPage} de {totalPages}"
                                     paginatorPosition="bottom" emptyMessage="Nenhum registro encontrado">

                            <f:facet name="header">
                                Usuário
                            </f:facet>
                            <p:column headerText="Ação" width="75">
                                <p:button  style="width: 20px; height: 20px;" 
                                           title="editar"
                                           href="editarusuario.xhtml?usuarioEditar=#{u.id}"
                                           icon="ui-icon-pencil"/>
                                <p:button  style="width: 20px; height: 20px;" 
                                           title="visualizar"
                                           href="visualizarusuario.xhtml?usuarioVisualizar=#{u.id}"
                                           icon="ui-icon-zoomin"/>
                                <p:button  style="width: 20px; height: 20px;" 
                                           title="Acesso"
                                           href="acessousuario.xhtml?userAcess=#{u.id}"
                                           icon="ui-icon-locked"/>
                            </p:column>
                            <p:column headerText="Nome" width="600">  
                                <h:outputText value="#{u.nome}"/>
                            </p:column>  
                            <p:column headerText="Login">  
                                <h:outputText value="#{u.login}"/>
                            </p:column>

                        </p:dataTable> 

                    </p:panel>

                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
